meaning of (\/?) in regex / is (\w+)([^>]*?) a redundancy?
Posted
by
thomas
on Stack Overflow
See other posts from Stack Overflow
or by thomas
Published on 2013-07-03T16:40:13Z
Indexed on
2013/07/03
17:05 UTC
Read the original article
Hit count: 158
JavaScript
|regex
this regular expression should match an html start tag, I think.
var results = html.match(/<(\/?)(\w+)([^>]*?)>/);
I see it should first capture the <
, but then I am confused what this capture (\/?)
accomplishes. Am I correct in reasoning that the ([^>]*?)>
searches for every character except >
>= 0 times? If so, why is the (\w+)
capture necessary? Doesn't it fall within the purview of [^>]*?
© Stack Overflow or respective owner